﻿@using Csla.Web.Mvc
@using ProjectTracker.Library

@model ProjectTracker.Library.ProjectEdit

@{
    ViewBag.Title = "Project details";
}

<h2>@ViewBag.Title</h2>

<fieldset>
    <legend>Project</legend>

    <div class="display-label">Name</div>
    <div class="display-field">@Model.Name</div>

    <div class="display-label">Description</div>
    <div class="display-field">@Model.Description</div>

    <div class="display-label">Started</div>
    @if (Model.Started.HasValue) {
    <div class="display-field">@String.Format("{0:d}", Model.Started)</div>
    } else {
      <div class="display-field">none</div>
    }

    <div class="display-label">Ended</div>
    @if (Model.Ended.HasValue)
    {
      <div class="display-field">@String.Format("{0:d}", Model.Ended)</div>
    }
    else
    {
      <div class="display-field">none</div>
    }

</fieldset>

<div>
<div class="display-label">Resources assigned</div>
<table>
<thead>
  <tr><td>Name</td><td>Assigned</td><td>Role</td></tr>
</thead>
<tbody>
@foreach (var item in Model.Resources) { 
  <tr><td>@Html.ActionLink(item.FullName, "Details", "Resource", new { id = item.ResourceId }, null)</td><td>@String.Format("{0:d}", item.Assigned)</td><td>@item.RoleName</td></tr>
}
</tbody></table>
</div>
<br />

<p>
    @Html.HasPermission(Csla.Rules.AuthorizationActions.EditObject, typeof(ProjectEdit), Html.ActionLink("Edit", "Edit", new { id = Model.Id }), "Edit") |
    @Html.ActionLink("Back to List", "Index")
</p>

